<template>
  <div class="cart">
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{length}})</div>
    </nav-bar>
    <!-- 1商品的列表 -->
    <cart-list></cart-list>
    <!-- 2底部汇总 -->
    <cart-bottom-bar></cart-bottom-bar>
  </div>
</template>

<script>
  import NavBar from '../../components/common/navbar/NavBar.vue';
  import CartBottomBar from './childComps/CartBottomBar.vue'
  // 这是vuex自带的 可将一些方法转变成计算属性
  import {mapGetters} from 'vuex'
  import CartList from './childComps/CartList.vue'
  export default {
    name: "Cart",
    components:{
      NavBar,
      CartList,
      CartBottomBar
    },
    computed:{
      // cartLength(){
      //   return this.$store.getters.cartLength
      // }
      // 两种用法 1.数组用法
      // ...mapGetters(['cartLength','cartList'])
      // 2.对象用法
      ...mapGetters({
        length : "cartLength",
        list : 'cartList'
      })
    }
  }
</script>

<style scoped>
  .nav-bar{
    background-color: var(--color-tint);
    color: white;
    /* 字体加粗 */
    /* font-weight: 700; */
  }

  .cart{
    height: 100vh;
  }
</style>
